<?php
/**
 * Created by PhpStorm.
 * User: hui
 * Date: 2017/2/21
 * Time: 07:03
 */
namespace app\common\traits;

trait Password
{
    protected $passwordCost = [
        'cost' => 10
    ];

    protected $passwordType = PASSWORD_DEFAULT;

    protected $passwordHash = '';

    protected function passwordHash($password)
    {
        if (config('?passwordCost')){
            $this->passwordCost = config('passwordCost');
        }
        return password_hash($password,$this->passwordType,$this->passwordCost);
    }

    protected function passwordVerify($password)
    {
        return password_verify($password,$this->passwordHash);
    }
}